package caiziyou.com.designpattern.principle.segregation.improve;
/**
 * 代码冗余
 * @author Administrator
 *
 */
public class SegregationDemo {

	public static void main(String[] args) {
		
		A a = new A();
		B b = new B();
		C c = new C();
		D d = new D();
		a.depend1(b);
		a.depend2(b);
		a.depend3(b);
		c.depend1(d);
		c.depend4(d);
		c.depend5(d);
	}
}

interface Interface1 {
	public void operater1();	
}

interface Interface2 {
	public void operater2();

	public void operater3();
}

interface Interface3 {
	public void operater4();

	public void operater5();
}

class B implements Interface1,Interface2 {

	@Override
	public void operater1() {
		System.out.println("B operater1 ");
	}

	@Override
	public void operater2() {
		System.out.println("B operater2 ");
	}

	@Override
	public void operater3() {
		System.out.println("B operater3 ");
	}


}

class D implements Interface1,Interface3 {

	@Override
	public void operater1() {
		System.out.println("D operater1 ");
	}
	@Override
	public void operater4() {
		System.out.println("D operater4 ");
	}

	@Override
	public void operater5() {
		System.out.println("D operater5 ");
	}

}

class A {
	public void depend1(Interface1 i) {
		i.operater1();
	}

	public void depend2(Interface2 i) {
		i.operater2();
	}

	public void depend3(Interface2 i) {
		i.operater3();
	}
}

class C {
	public void depend1(Interface1 i) {
		i.operater1();
	}
	public void depend4(Interface3 i) {
		i.operater4();
	}

	public void depend5(Interface3 i) {
		i.operater5();
	}
	
}
